import { defineStore } from 'pinia'
import { ref } from 'vue'
import type * as energy from "@/api/energy.ts";

export const useEnergyCheck = defineStore(
	'energyCheck',
	() => {

		//当前电表
		const key = ref<string>()
		//当月数据
		const data = ref<energy.DataByTUOKs>()
		//上月数据
		const lastData = ref<energy.DataByTUOKs>()

		//用电组成所需数据
		const type = ref<energy.GartherType>()
		const pobj = ref<energy.ProjectObjectsModusItem[]>()
		const pobjData = ref<energy.DataByTUOKs>()

		const setKey = (val : string) => {
			key.value = val
		}

		const setType = (val : energy.GartherType) => {
			type.value = val
		}


		const setData = (val : energy.DataByTUOKs) => {
			data.value = val
		}

		const setLastData = (val : energy.DataByTUOKs) => {
			lastData.value = val
		}
		
		const setPobj = (val : energy.ProjectObjectsModusItem[]) => {
			pobj.value = val
		}
		
		const setPobjData = (val : energy.DataByTUOKs) => {
			pobjData.value = val
		}
		
		const clearData = () => {
			key.value = undefined
			type.value = undefined
			data.value = undefined
			lastData.value = undefined
			pobj.value = undefined
			pobjData.value = undefined
		}

		return {
			key,
			type,
			setKey,
			setType,
			pobj,
			pobjData,
			data,
			lastData,
			setData,
			setLastData,
			setPobj,
			setPobjData,
			clearData,
		}
	}
)